<!DOCTYPE html>












  


<html class="theme-next pisces use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2"/>
<meta name="theme-color" content="#222">






  
  
    
      
    
    
      
    
  <script src="https://cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
  <link href="https://cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-flash.min.css" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />






















  

<link href="https://cdn.bootcss.com/font-awesome/4.6.2/css/font-awesome.min.css" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=6.3.0" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=6.3.0">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=6.3.0">


  <link rel="mask-icon" href="/images/logo.svg?v=6.3.0" color="#222">









<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '6.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: false,
    fastclick: false,
    lazyload: false,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>


  




  <meta name="description" content="前端部署nginx配置之前很少接触前端项目的部署，这次为了更全面的学习就在本机上装了一个虚拟机上，在虚拟机上练习了如何把一个 react 写的 spa 项目部署到这个虚拟机的服务器上。由于 linux 也是刚接触不久，所以整个过程还是遇到了很多坑，这里记录下。 目标我有一个用 react 写的单页面应用，然后希望部署到服务器上，通过 ip 如 192.168.1.240/config 这种路径下访">
<meta name="keywords" content="nginx,部署">
<meta property="og:type" content="article">
<meta property="og:title" content="前端部署nginx配置">
<meta property="og:url" content="http://yoursite.com/2018/08/03/前端部署nginx配置/index.html">
<meta property="og:site_name" content="三月的米店">
<meta property="og:description" content="前端部署nginx配置之前很少接触前端项目的部署，这次为了更全面的学习就在本机上装了一个虚拟机上，在虚拟机上练习了如何把一个 react 写的 spa 项目部署到这个虚拟机的服务器上。由于 linux 也是刚接触不久，所以整个过程还是遇到了很多坑，这里记录下。 目标我有一个用 react 写的单页面应用，然后希望部署到服务器上，通过 ip 如 192.168.1.240/config 这种路径下访">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://yoursite.com/2018/08/03/前端部署nginx配置/4282315052.jpg">
<meta property="og:updated_time" content="2018-11-29T02:09:38.115Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="前端部署nginx配置">
<meta name="twitter:description" content="前端部署nginx配置之前很少接触前端项目的部署，这次为了更全面的学习就在本机上装了一个虚拟机上，在虚拟机上练习了如何把一个 react 写的 spa 项目部署到这个虚拟机的服务器上。由于 linux 也是刚接触不久，所以整个过程还是遇到了很多坑，这里记录下。 目标我有一个用 react 写的单页面应用，然后希望部署到服务器上，通过 ip 如 192.168.1.240/config 这种路径下访">
<meta name="twitter:image" content="http://yoursite.com/2018/08/03/前端部署nginx配置/4282315052.jpg">






  <link rel="canonical" href="http://yoursite.com/2018/08/03/前端部署nginx配置/"/>



<script type="text/javascript" id="page.configurations">
  CONFIG.page = {
    sidebar: "",
  };
</script>

  <title>前端部署nginx配置 | 三月的米店</title>
  









  <noscript>
  <style type="text/css">
    .use-motion .motion-element,
    .use-motion .brand,
    .use-motion .menu-item,
    .sidebar-inner,
    .use-motion .post-block,
    .use-motion .pagination,
    .use-motion .comments,
    .use-motion .post-header,
    .use-motion .post-body,
    .use-motion .collection-title { opacity: initial; }

    .use-motion .logo,
    .use-motion .site-title,
    .use-motion .site-subtitle {
      opacity: initial;
      top: initial;
    }

    .use-motion {
      .logo-line-before i { left: initial; }
      .logo-line-after i { right: initial; }
    }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">三月的米店</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
    
      
        <h1 class="site-subtitle" itemprop="description">今儿不吃饭</h1>
      
    
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>



<nav class="site-nav">
  
    <ul id="menu" class="menu">
      
        
        
        
          
          <li class="menu-item menu-item-home">
    <a href="/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-tags">
    <a href="/tags/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />标签</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-categories">
    <a href="/categories/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-th"></i> <br />分类</a>
  </li>
        
        
        
          
          <li class="menu-item menu-item-archives">
    <a href="/archives/" rel="section">
      <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档</a>
  </li>

      
      
    </ul>
  

  

  
</nav>



  



</div>
    </header>

    


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          
            

          
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/08/03/前端部署nginx配置/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Mark Lee">
      <meta itemprop="description" content="折腾小久的博客,在 2018-08-01 终于基本成型啦，以后就常驻啦">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="三月的米店">
    </span>

    
      <header class="post-header">

        
        
          <h2 class="post-title" itemprop="name headline">前端部署nginx配置
              
            
          </h2>
        

        <div class="post-meta">
          <span class="post-time">

            
            
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              

              
                
              

              <time title="创建时间：2018-08-03 12:56:43" itemprop="dateCreated datePublished" datetime="2018-08-03T12:56:43+08:00">2018-08-03</time>
            

            
              

              
                
                <span class="post-meta-divider">|</span>
                

                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                
                  <span class="post-meta-item-text">更新于</span>
                
                <time title="修改时间：2018-11-29 10:09:38" itemprop="dateModified" datetime="2018-11-29T10:09:38+08:00">2018-11-29</time>
              
            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/前端/" itemprop="url" rel="index"><span itemprop="name">前端</span></a></span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="前端部署nginx配置"><a href="#前端部署nginx配置" class="headerlink" title="前端部署nginx配置"></a>前端部署nginx配置</h1><p>之前很少接触前端项目的部署，这次为了更全面的学习就在本机上装了一个虚拟机上，在虚拟机上练习了如何把一个 <code>react</code> 写的 <code>spa</code> 项目部署到这个虚拟机的服务器上。由于 <code>linux</code> 也是刚接触不久，所以整个过程还是遇到了很多坑，这里记录下。</p>
<h2 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h2><p>我有一个用 <code>react</code> 写的单页面应用，然后希望部署到服务器上，通过 <code>ip</code> 如 <code>192.168.1.240/config</code> 这种路径下访问到我的应用。这个 <code>react</code> 项目依赖一个 <code>node.js</code> 的一个 <code>api</code> 服务，我需要在 <code>nginx</code> 上配置代理使得我的 <code>react</code> 应用能够访问到我的 <code>api</code> 服务。</p>
<h2 id="准备"><a href="#准备" class="headerlink" title="准备"></a>准备</h2><p>首先要准备的就是打包好的的 <code>react</code> 应用，然后在服务器上装一个 <code>nginx</code> 和一个 <code>node.js</code>。</p>
<p>针对我这个项目, 我把 <code>react</code> 打包好的项目全部放到了 <code>/root/html/pageConfig</code> 这个路径下。</p>
<h2 id="nginx配置"><a href="#nginx配置" class="headerlink" title="nginx配置"></a>nginx配置</h2><p>修改 <code>nginx</code> 安装目录下的 <code>./conf/nginx.conf</code> 文件：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line">#user nodody;</span><br><span class="line"># 1. 由于我的 react 项目打包出来放在 root 目录下，需要设置user 为 root 时内容才能够被访问</span><br><span class="line">user root;</span><br><span class="line"></span><br><span class="line">worker_processes  1;</span><br><span class="line"></span><br><span class="line">#error_log  logs/error.log;</span><br><span class="line">#error_log  logs/error.log  notice;</span><br><span class="line">#error_log  logs/error.log  info;</span><br><span class="line"></span><br><span class="line">#pid        logs/nginx.pid;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">events &#123;</span><br><span class="line">    worker_connections  1024;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">http &#123;</span><br><span class="line">    include       mime.types;</span><br><span class="line">    default_type  application/octet-stream;</span><br><span class="line"></span><br><span class="line">    #log_format  main  &apos;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &apos;</span><br><span class="line">    #                  &apos;$status $body_bytes_sent &quot;$http_referer&quot; &apos;</span><br><span class="line">    #                  &apos;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&apos;;</span><br><span class="line"></span><br><span class="line">    #access_log  logs/access.log  main;</span><br><span class="line"></span><br><span class="line">    sendfile        on;</span><br><span class="line">    #tcp_nopush     on;</span><br><span class="line"></span><br><span class="line">    #keepalive_timeout  0;</span><br><span class="line">    keepalive_timeout  65;</span><br><span class="line"></span><br><span class="line">    #gzip  on;</span><br><span class="line"></span><br><span class="line">    server &#123;</span><br><span class="line">        listen       80;</span><br><span class="line">        server_name  localhost;</span><br><span class="line"></span><br><span class="line">        #charset koi8-r;</span><br><span class="line"></span><br><span class="line">        #access_log  logs/host.access.log  main;</span><br><span class="line"></span><br><span class="line">        location / &#123;</span><br><span class="line">            root   html;</span><br><span class="line">            index  index.html index.htm;</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        # 2. 对我的/api请求转发到8989端口下node.js服务</span><br><span class="line">        location /api &#123;</span><br><span class="line">            proxy_pass  http://127.0.0.1:8989;</span><br><span class="line">        &#125;</span><br><span class="line">        # 3. 在/config下的请求都指向到我放在root下的configPage里的内容</span><br><span class="line">         location /config &#123;</span><br><span class="line">            alias /root/html/configPage;</span><br><span class="line">            index index.html index.htm;</span><br><span class="line">            #rewrite /config  /root/html/configPage/index.html;</span><br><span class="line">            try_files $uri $uri/ /config/index.html;</span><br><span class="line">         &#125;</span><br><span class="line"></span><br><span class="line">        #error_page  404              /404.html;</span><br><span class="line"></span><br><span class="line">        # redirect server error pages to the static page /50x.html</span><br><span class="line">        #</span><br><span class="line">        error_page   500 502 503 504  /50x.html;</span><br></pre></td></tr></table></figure>
<p>这里就是只修改了默认配置文件的三个地方，来满足我的要求：</p>
<ol>
<li>修改 <code>user</code> 为 <code>root</code>，使得 <code>root</code> 下的内容能够被访问</li>
<li>新增 <code>location /api</code> 设置 <code>proxy_pass</code> 使得 <code>/api</code>下的请求都被转发到 <code>proxy_pass</code> 设置的 <code>node.js</code> 服务处,满足我的前端页面 <code>api</code> 接口代理的问题</li>
<li>新增 <code>location /config</code> 的配置，使得 <code>/config</code> 下请求都转发至我 <code>react</code> 打包文件所在的路径。这样我访问 <code>192.168.1.240/config</code>就能看到我的页面。<em>这里我当初是复制的<code>location /</code> 的配置，用的也是 <code>root</code> 指向路径，结果一直不行，查了资料，发现应该要写成 <code>alias</code> 才行</em></li>
</ol>
<p>这里的配置文件可能需要更改多次，才能成功，需要注意的是，每次修改完 <code>nginx</code> 配置，需要重启下 <code>nginx</code>:</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">nginx -s reload</span><br></pre></td></tr></table></figure>
<h2 id="静态资源路径问题"><a href="#静态资源路径问题" class="headerlink" title="静态资源路径问题"></a>静态资源路径问题</h2><p>把打包好的文件传到服务器上的时候，可能出现静态资源文件找不到的情况。</p>
<h3 id="资源路径找不到的原因"><a href="#资源路径找不到的原因" class="headerlink" title="资源路径找不到的原因"></a>资源路径找不到的原因</h3><p>可能的原因是当 <code>react</code> 应用打包的时候，生成 <code>index.html</code> 文件中插入 <code>style</code> 和 <code>script</code> 标签的路径不对，从而找不到静态资源。</p>
<h3 id="静态资源找不到的解决方法"><a href="#静态资源找不到的解决方法" class="headerlink" title="静态资源找不到的解决方法"></a>静态资源找不到的解决方法</h3><p>需要在 <code>webpack</code> 的配置文件中去修改一下 <code>publicPath</code> 这个属性，这个属性会影响你的静态资源文件插入到 <code>index.html</code> 中的路径。像我这个项目设置 <code>publicPath: &#39;./&#39;</code>就可以了，具体可以多修改几次多打包几次试试就行了。</p>
<h2 id="前端路由"><a href="#前端路由" class="headerlink" title="前端路由"></a>前端路由</h2><h3 id="前端路由分类"><a href="#前端路由分类" class="headerlink" title="前端路由分类"></a>前端路由分类</h3><p>前端路由分为两种实现，一种就是 <code>hashRouter</code>，另一种就是用 <code>H5</code> 新的 <code>History API</code> 实现的 <code>browserRouter</code>。由于 <code>hashRouter</code> 的路径带一个 <code>#</code> 不是特别好看，一般还是用 <code>browserRouter</code> 较多。</p>
<h3 id="前端路由的问题"><a href="#前端路由的问题" class="headerlink" title="前端路由的问题"></a>前端路由的问题</h3><p>前端路由说白了就是路径变了，不去请求服务器，而是用 <code>js</code> 去改变页面的方式。这样的话，用 <code>browserRouter</code> 的话这里就存在一个问题，我用前端路由跳转到某一个路径下 <code>/xxx</code>，这是我刷新页面，这时候就会去服务器上拿资源，这个前端路由路径下肯定找不到资源，所以就会出现 <code>404</code> 报错。</p>
<h3 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h3><p>解决页面刷新 <code>404</code> 这个问题，只需要把所有的请求全部返回 <code>index.html</code>，可以搜索 <code>history fallback</code> 这个关键词查看相关资料。</p>
<p>针对我的这个 <code>nginx</code> 配置而言，只需要加入 <code>try_files $uri $uri/ /config/index.html;</code>,就能把前端路由路径发送给服务器时全部返回 <code>index.html</code>，这样就解决了 <code>404</code>问题。</p>
<h2 id="Route路径匹配问题"><a href="#Route路径匹配问题" class="headerlink" title="Route路径匹配问题"></a>Route路径匹配问题</h2><p>配置好上述的 <code>nginx</code> 以及把打包好的文件放到对应的目录，再把我的 <code>api</code> 服务启动，再访问 <code>192.168.1.240/config</code> 时，已经能够正常的显示页面，并且接口也能正常代理请求到了。但是涉及到路由的页面却没有被渲染出来。</p>
<h3 id="Route路径匹配的原因"><a href="#Route路径匹配的原因" class="headerlink" title="Route路径匹配的原因"></a>Route路径匹配的原因</h3><p>回想一下，在 <code>react-router-dom</code> 的 <code>Route</code> 标签里传递一个 <code>path={&#39;/xx&#39;}</code> 的属性时，前端路由会根据这个 <code>path</code> 来渲染对应的 <code>Route</code> 上传递过去的 <code>Component</code> 组件。那么在我的 <code>nginx</code> 的设置中，我设置的是 <code>location /config</code>，也就是说我实际访问路径都是加上了前缀 <code>/config</code>，所以每个 <code>Route</code> 标签中传过去的路径都因为缺少了 <code>/config</code> 前缀导致所以的匹配都不成立，所以 <code>Route</code> 的页面都没有办法渲染。</p>
<h3 id="Route路径匹配修改方法"><a href="#Route路径匹配修改方法" class="headerlink" title="Route路径匹配修改方法"></a>Route路径匹配修改方法</h3><p>方法很简单，在 <code>BrowserRouter</code> 上加一个 <code>basename</code> 的属性，给这属性传递 <code>config</code> (<em>具体是什么值，依据你给 <code>nginx</code>设置 <code>location</code> 时的前缀，我的例子中是 <code>config</code></em>)，这样 <code>Route</code> 在匹配路径的时候会加上 <code>basename</code>，这样就能和对应路径匹配上，然后渲染对应页面。</p>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>对 <code>linux</code> 不熟悉，<code>nginx</code> 也不熟悉，依靠着百度，摸爬滚打尝试修改了好多次 <code>nginx</code> 配置，终于能够 <code>react</code> 打包好的文件部署上去了， <code>vue</code> 项目的部署也是没什么区别的。</p>
<hr>
<p><img src="/2018/08/03/前端部署nginx配置/4282315052.jpg" alt="Raffaello Sanzio da Urbino) Raphael (Raffaello Santi – Saint George and the Dragon"></p>
<blockquote>
<p>Raffaello Sanzio da Urbino) Raphael (Raffaello Santi – Saint George and the Dragon 1503-05</p>
</blockquote>

      
    </div>

    

    
    
    

    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/nginx/" rel="tag"><i class="fa fa-tag"></i> nginx</a>
          
            <a href="/tags/部署/" rel="tag"><i class="fa fa-tag"></i> 部署</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/08/03/一次面试记录/" rel="next" title="一次面试记录">
                <i class="fa fa-chevron-left"></i> 一次面试记录
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/08/03/redux之compose/" rel="prev" title="redux之compose">
                redux之compose <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


  </div>


          </div>
          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Mark Lee</p>
              <p class="site-description motion-element" itemprop="description">折腾小久的博客,在 2018-08-01 终于基本成型啦，以后就常驻啦</p>
          </div>

          
            <nav class="site-state motion-element">
              
                <div class="site-state-item site-state-posts">
                
                  <a href="/archives/">
                
                    <span class="site-state-item-count">26</span>
                    <span class="site-state-item-name">日志</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-categories">
                  <a href="/categories/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">4</span>
                    <span class="site-state-item-name">分类</span>
                  </a>
                </div>
              

              
                
                
                <div class="site-state-item site-state-tags">
                  <a href="/tags/index.html">
                    
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                      
                    
                    <span class="site-state-item-count">20</span>
                    <span class="site-state-item-name">标签</span>
                  </a>
                </div>
              
            </nav>
          

          

          

          
          

          
          

          
            
          
          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#前端部署nginx配置"><span class="nav-number">1.</span> <span class="nav-text">前端部署nginx配置</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#目标"><span class="nav-number">1.1.</span> <span class="nav-text">目标</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#准备"><span class="nav-number">1.2.</span> <span class="nav-text">准备</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#nginx配置"><span class="nav-number">1.3.</span> <span class="nav-text">nginx配置</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#静态资源路径问题"><span class="nav-number">1.4.</span> <span class="nav-text">静态资源路径问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#资源路径找不到的原因"><span class="nav-number">1.4.1.</span> <span class="nav-text">资源路径找不到的原因</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#静态资源找不到的解决方法"><span class="nav-number">1.4.2.</span> <span class="nav-text">静态资源找不到的解决方法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#前端路由"><span class="nav-number">1.5.</span> <span class="nav-text">前端路由</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#前端路由分类"><span class="nav-number">1.5.1.</span> <span class="nav-text">前端路由分类</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#前端路由的问题"><span class="nav-number">1.5.2.</span> <span class="nav-text">前端路由的问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#解决方案"><span class="nav-number">1.5.3.</span> <span class="nav-text">解决方案</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Route路径匹配问题"><span class="nav-number">1.6.</span> <span class="nav-text">Route路径匹配问题</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#Route路径匹配的原因"><span class="nav-number">1.6.1.</span> <span class="nav-text">Route路径匹配的原因</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Route路径匹配修改方法"><span class="nav-number">1.6.2.</span> <span class="nav-text">Route路径匹配修改方法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#总结"><span class="nav-number">1.7.</span> <span class="nav-text">总结</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Mark Lee</span>

  

  
</div>


  


<!--

  <div class="powered-by">由 <a class="theme-link" target="_blank" rel="external nofollow" href="https://hexo.io">Hexo</a> 强力驱动 v3.7.1</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" rel="external nofollow" href="https://theme-next.org">NexT.Pisces</a> v6.3.0</div>

-->



        








        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    
	
    

    
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>


























  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=6.3.0"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=6.3.0"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=6.3.0"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=6.3.0"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=6.3.0"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=6.3.0"></script>



  



  










  





  

  

  

  

  
  

  

  

  

  

  

</body>
</html>
